<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@ taglib prefix="d" uri="http://dgg.net/jsp/jstl/core" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>节点超期扣罚</title>
    <jsp:include page="/WEB-INF/jsp/header.jsp"/>
</head>
<body>
<div class="body-main">
    <div class="main-title">
		<span class="bus-state">
			<font>节点超期扣罚</font>
		</span>
    </div>
    <div class="titleSearch">
        <div class="layui-inline">
            <label>所属生产事业部：</label>
            <div class="layui-input-inline">
                <select name="productOrgId" id="productOrgId"  class="select-style" onchange="changUser('#flowUserId')">
                    <option value>请选择</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label>流程人员：</label>
            <div class="layui-input-inline">
                <%--通过deptid  事业部id 和roleCode 角色代码开进行回显， flsc-select-content 为 flowUserId 获取指定事业部下拥有指定角色的所有人员--%>
                <select name="flowUserId" id="flowUserId" class="select-style">
                    <option value>请选择</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label>扣罚时间：</label>
            <div class="layui-input-inline">
                <input type="text" name="punishStartTime" placeholder="开始日期" class="Wdate input-style" id="d4311"
                       onFocus="var d4312=$dp.$('d4312'); WdatePicker({onpicked:function(){d4312.focus();}, maxDate:'#F{ $dp.$D(\'d4312\')}', dateFmt:'yyyy-MM-dd'})">
            </div>
            <span>~</span>
            <div class="layui-input-inline">
                <input type="text" name="punishEndTime" placeholder="结束日期" class="Wdate input-style" id="d4312"
                       onFocus="WdatePicker({minDate:'#F{$dp.$D(\'d4311\')}', dateFmt:'yyyy-MM-dd'})">
            </div>
        </div>
        <div class="layui-inline">
            <button type="button" class="layui-btn layui-btn-mini layui-btn-normal"
                    onclick="dataTableReload()">搜索
            </button>
            <button type="button" class="layui-btn layui-btn-mini layui-btn-primary"
                    onclick="cleanSearch()">
                清空
            </button>
            <button class="layui-btn layui-btn-mini layui-btn-green" onclick="exportExcel('/flsc/nodeOverdue/exportDeductionRecordExcel.do')">导出</button>
        </div>
    </div>
    <div class="table-conter">

    </div>
    <div class="table-body">
        <!--表格 end-->
        <table class="cell-border crm-table columnsHidden dataTable" id="table">
            <thead>
                <tr>
                <th width="50">序号</th>
                <th>人员</th>
                <th>生产事业部</th>
                <th>订单编号</th>
                <th >生产单编号</th>
                <th >工单编号</th>
                <th >客户名称</th>
                <th>超期节点</th>
                <th>超期日期</th>
                <th>扣罚日期</th>
                <th>扣罚操行分</th>
                <th>扣罚金额</th>
                <th>状态</th>
                <th>审核人</th>
                <th>操作</th>
            </tr>

            </thead>
        </table>
    </div>
    <%--保存当前登录用户--%>
    <input id="userId" type="hidden" value=${user.id}  />
</div>
<jsp:include page="/WEB-INF/jsp/footer.jsp"/>
<script type="text/javascript"
        src="${basePath}/static/js/choose.extend.js?v=${version}"></script>
<script type="text/javascript" src="${basePath}/static/js/zzsc/production/sc_common.js?v=${version}"></script>
<script type="text/javascript" src="${basePath}/static/js/overdue_deduction.js?v=${version}"></script>
<script src="${rootUrl}/static/js/zzsc/common/sc_chooseUser.js?v=${version}" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">



    //页面加载完毕，查询数据
    var table;
    $(document).ready(function () {
        table = $('#table').dataTableExtend({
            "ajax": {"url": "${basePath}/flsc/nodeOverdue/deductionRecord.do", "type": "get"},
            "fnServerParams": function (aoData) {
                aoData = $.extend(aoData, {}, $('.titleSearch').serializeJson());
                return aoData;
            },
            "scrollX": false,//是否开启横项滚动
            "fixedColumns": {//锁定列，只有开启scrollX时才生效
                "leftColumns": 3,//左侧锁定2列
                "rightColumns": 1//右侧锁定1列
            },
            "aoColumns": [
                {
                    "orderable": false,
                    "render": function (data, type, full, meta) {
                        return meta.row + 1;
                    }
                }, {
                    "orderable": false,
                    "data": "flowUserName",
                    "render": function (data, type, full, meta) {
                        return data ?  data : '-';
                    }
                }, {
                    "orderable": false,
                    "data": "productOrgName",
                    "render": function (data, type, full, meta) {
                        return data ? data : '-';
                    }
                }, {
                    "orderable": false,
                    "data": "orderNo",
                    "render": function (data, type, full, meta) {
                        if(!data){
                            return '';
                        }else{
                           // return '<a href="javascript:;"  class="layui-table-link" onclick="openBusinessDetail(\'' + full.orderNo + '\',\'' + full.orderId + '\')" /><p>' + data + '</p></a>';
                            return data;
                        }
                    }
                },{
                    "orderable": false,
                    "data": "productOrderNo",
                    "render": function (data, type, full, meta) {
                        //return data ? '<a href="javascript:;"  class="layui-table-link" onclick="openOrderInfoDetail(\'' + full.productOrderNo + '\',\'' + full.productOrderId + '\')" />' + data + '</a>' : '-';
                        return data ? data : '-';
                    }
                }, {//工单编号
                "orderable": false,
                    "data": "workOrderNo",
                    "render": function (data, type, full, meta) {
                         return  data ?  data : '-';
                    }
                },{//客户名称
                    "orderable": false,
                    "data": "customerName",
                    "render": function (data, type, full, meta) {
                        return data?data:"";
                    }
                },{
                    "orderable": false,
                    "data": "noName",
                    "render": function (data, type, full, meta) {
                        return data ?  data : '-';
                    }
                }, {
                    "orderable": false,
                    "data": "timeOutTime",
                    "render": function (data, type, full, meta) {
                        if(null == data){
                            return '-';
                        }else{
                            data = new Date(data).getTime();
                            return  new Date(data).format("yyyy-MM-dd");
                        }
                    }
                }, {
                    "orderable": false,
                    "data": "punishTime",
                    "render": function (data, type, full, meta) {
                        if(null == data){
                            return '-';
                        }else{
                            data = new Date(data).getTime();
                            return   new Date(data).format("yyyy-MM-dd") ;
                        }
                    }
                }, {
                    "orderable": false,
                    "data": "points",
                    "render": function (data, type, full, meta) {
                        return  null != data? data  : '-';
                    }
                }, {
                    "orderable": false,
                    "data": "money",
                    "render": function (data, type, full, meta) {
                        return  null != data ?  data  : '-';
                    }
                }, {
                    "orderable": false,
                    "data": "status",
                    "render": function (data, type, full, meta) {
                        return data ?  data : '';
                    }
                },
                {
                    "orderable": false,
                    "data": "reviewerName",
                    "render": function (data, type, full, meta) {
                        return data ?  data : '';
                    }
                },{
                    "orderable": false,
                    "render": function (data, type, full, meta) {
                        var result = "";

                        //已经在申诉阶段
                        if( $("#userId").val()  ==full.flowUserId  && full.state==1){
                            result +='<a href=\'javascript:void(0)\' class="iboss-link"  onclick="deductionAppeal(\'' + full.id + '\')" />申诉</a>';
                        }
                       /* if(full.status !='未申诉' && $("#userId").val()  ==full.flowUserId){
                            result += '<a href=\'javascript:void(0)\' class="iboss-link"  onclick="deductionAppealReview(\''+full.id+'\',\''+full.appealId+'\')" />申诉记录</a>';
                        }*/
                        return result;
                    }
                }],
            "columnDefs": []
        });
        signOrgTreeBookCode('[name="productOrgId"]')
        chooseUserPlug.init($('#flowUserId'),{
            url:sysInfo.basePath+'/zzsc/common/find_user_choose.do',
            otherParam:{
                /**
                 * type: 用户信息选择类型（必填）
                 *       all:全部用户，division：当前登录人所在事业部，department:当前登录人所在部门及以下，role: 查询指定角色用户，
                 * roleCode : 角色Code，（type为role时，必填）
                 * locked: 用户状态，（选填，默认全部状态）
                 *      0、正常；1、锁定；2、离职
                 */
                type:'division',
                locked:0
            }
        });

    });
    function signOrgTreeBookCode(obj) {
        $(obj).find("option").remove();
        $(obj).append("<option value=''>请选择</option>");
        $.post(sysInfo.basePath + '/zzsc/common/find_all_syb.do', function (result) {
            if (result.code == 0) {
                $.each(result.data, function (i, item) {
                    $(obj).append("<option value='" + item.id + "'>" + item.name + "</option>");
                });
            } else {
                DGG.Errors("系统错误，请联系管理员");
            }
        });
        $(obj).select2({
            placeholder: "请选择",
            allowClear: true,
            width: "150px",
            language: "zh-CN"
        });
    }
    function changUser(obj) {
        console.log(obj);
        $(obj).find("option").remove();
        $(obj).append("<option value=''>请选择</option>");
        $.post(sysInfo.basePath + '/zzsc/common/find_user_choose.do',{organId:$("#signOrgId").val(), locked:0}, function (result) {
            if (result.code == 0) {
                console.log(result.data);
                $.each(result.data, function (i, item) {
                    $(obj).append("<option value='" + item.id + "'>" + item.realName+item.loginName + "</option>");
                });
            } else {
                DGG.Errors("系统错误，请联系管理员");
            }
        });
        $(obj).select2({
            placeholder: "请选择",
            allowClear: true,
            width: "200px",
            language: "zh-CN"
        });
    }

    /**
     * 导出到excel
     */
    function exportExcel(url) {
        var data = $('.titleSearch').serializeJson();
        //判断参数是否为空
        if(Object.keys(data).length ==0){
            DGG.Layer.message("必须选择搜索条件才能进行导出", {icon: '1'});
            return false;
        }
        export_table(url, data);
    }
    function deductionAppealReview(id,appealId) {
        if (isEmpty(id)  || isEmpty(appealId)  ) {
            DGG.Layer.message("未获取到申诉id，请刷新页面", {icon: '1'});
            return false;
        }
        DGG.Layer.loading.start();
        DGG.Layer.open(sysInfo.basePath + "/flsc/nodeOverdue/reviewRecordHtml.html?id=" + id+"&appealId="+appealId, {
            title: '申诉记录',
            area: ['900px', '90%'],
            btn: "",
            success: function(layero, index){
                DGG.Layer.loading.done();
            }
        });
    }


</script>
</body>
</html>